package com.free.chat.entity;

import com.free.chat.common.CustomResponse;
import lombok.Data;

/**
 * @Author: 朝花不迟暮
 * @Date: 2021/12/23 22:27
 * @Description:
 */
@Data
public class ApiResult {
    /**
     * 错误码.
     */
    private Integer code;

    /**
     * 提示信息.
     */
    private String msg;

    /**
     * 具体的内容.
     */
    private Object data;

    public static ApiResult success(Object object) {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(CustomResponse.SUCCESS.getCode());
        apiResult.setMsg(CustomResponse.SUCCESS.getMsg());
        apiResult.setData(object);
        return apiResult;
    }

    public static ApiResult success() {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(CustomResponse.SUCCESS.getCode());
        apiResult.setMsg(CustomResponse.SUCCESS.getMsg());
        return apiResult;
    }

    public static ApiResult successMsg(String msg) {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(CustomResponse.SUCCESS.getCode());
        apiResult.setMsg(msg);
        return apiResult;
    }

    public static ApiResult success(Integer code, String msg, Object obj) {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(code);
        apiResult.setMsg(msg);
        apiResult.setData(obj);
        return apiResult;
    }


    public static ApiResult error(String msg) {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(CustomResponse.FAILURE.getCode());
        apiResult.setMsg(msg);
        return apiResult;
    }

    public static ApiResult error() {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(CustomResponse.FAILURE.getCode());
        apiResult.setMsg(CustomResponse.FAILURE.getMsg());
        return apiResult;
    }

    public static ApiResult error(Integer code, String msg, Object obj) {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(code);
        apiResult.setMsg(msg);
        apiResult.setData(obj);
        return apiResult;
    }

    public static ApiResult unAuthorization() {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(CustomResponse.UN_AUTHORIZATION.getCode());
        apiResult.setMsg(CustomResponse.UN_AUTHORIZATION.getMsg());
        return apiResult;
    }
}